package cn.xy.base.server.dto;

import cn.hutool.core.bean.BeanUtil;
import cn.xy.base.server.po.SysRole;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;

/**
 * 表[sys_role]对应UpdateDTO类
 *
 * @author auto
 */

@Data
public class SysRoleUpdateDTO {

    /**
     * 自增id
     */
    @Min(value = 1, message = "ID不能为空")
    @ApiModelProperty(value = "自增id", dataType = "Integer")
    private Integer id;

    /**
     * 角色名称
     */
    @NotEmpty(message = "角色名称不能为空")
    @ApiModelProperty(value = "角色名称", dataType = "String")
    private String roleName;

    /**
     * 特殊角色标识
     */
    @NotEmpty(message = "key不能为空")
    @ApiModelProperty(value = "特殊角色标识", dataType = "String")
    private String key;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注", dataType = "String")
    private String remark;

    /**
     * 权限id，多个以逗号分隔
     */
    @NotEmpty(message = "权限列表不能为空")
    @ApiModelProperty(value = "权限id，多个以逗号分隔", dataType = "String")
    private String permissions;

    public SysRole toSysRole() {
        SysRole sysRole = new SysRole();
        BeanUtil.copyProperties(this, sysRole);
        return sysRole;
    }
}
